package ysc.cqnu.operdb.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import ysc.cqnu.operdb.entity.Roughsketch;

import java.util.List;

@Mapper
@Component
public interface DrawingMapper {
    //分页
    @Select("select * from roughsketch limit #{begin},#{end}")
    public List<Roughsketch> fenye(Integer begin, Integer end);

    //画图信息详情
    @Select("select * from roughsketch where id=#{id}")
    public Roughsketch huatudetails(String id);

    //查询表中总的记录条数
    @Select("select count(*) from roughsketch")
    public Integer count();

    //将画图信息插入表roughsketch中
    @Insert("insert into roughsketch(drawname,visualize,purpose,theSite,rsImg,rsVideo,bfDescribe,uploader,uploadDate) values (#{drawname},#{visualize},#{purpose},#{theSite},#{rsImg},#{rsVideo},#{describe},#{uploader},#{uploadDate})")
    public int insertDrawingInfo(String drawname, String visualize, String purpose, String theSite, String rsImg, String rsVideo, String describe, String uploader, String uploadDate);

    //根据画稿名、人物形象、用途、具体部位、上传日期、上传人查找
    @Select("select * from roughsketch where drawname=#{drawname} and visualize=#{visualize} and purpose=#{purpose} and theSite=#{theSite} and uploader=#{uploader} and uploadDate=#{uploadDate}")
    public Roughsketch chazhaoDrawingInfo(String drawname,String visualize,String purpose,String theSite,String uploader,String uploadDate);

    //根据id获取该条记录是表中第几条数据
    @Select("select count(*) from (select * from roughsketch order by id) as roughsketch where id <=(select id from roughsketch where id=#{id})")
    public int drawingInfoSite(String id);

    //验证录入的画图信息是否重复
    @Select("select * from roughsketch where drawname=#{drawname} and uploader=#{uploader}")
    public Roughsketch drawingInfoRepetiton(String drawname, String visualize, String purpose, String theSite, String uploader);
    //修改画图信息
    @Update("update roughsketch set visualize=#{visualize},purpose=#{purpose},theSite=#{theSite},rsImg=#{rsImg},rsVideo=#{rsVideo},bfDescribe=#{bfDescribe} where id=#{id}")
    public int updateDrawingInfo(String visualize, String purpose, String theSite, String rsImg, String rsVideo, String bfDescribe, String id);
    //按id删除记录
    @Delete("delete from roughsketch where id=#{id}")
    public int deleteDrawingInfoByid(String id);
    //修改画图无图片视频信息
    @Update("update roughsketch set visualize=#{visualize},purpose=#{purpose},theSite=#{theSite},bfDescribe=#{bfDescribe} where id=#{id}")
    public int updateDrawingInfoNoImg(String visualize, String purpose, String theSite, String bfDescribe, String id);
    //将画图信息插入表roughsketch中
    @Insert("insert into roughsketchZZ(drawname,visualize,purpose,theSite,rsImg,rsVideo,bfDescribe) values (#{drawname},#{visualize},#{purpose},#{theSite},#{rsImg},#{rsVideo},#{describe})")
    public int insertDrawingInfoZZ(String drawname, String visualize, String purpose, String theSite, String rsImg, String rsVideo, String describe);
    //查找所有信息
    @Select("select * from roughsketch")
    public List<Roughsketch> findAllFromroughsketch();
}
